import request from '@/utils/request';
import { PageResponse } from '@/interface/pages';

/**
 * 获取分页列表
 *
 * @returns Promise
 *
 * @todo 发起axios请求
 */
export const getQuickList = (params: API.quick.PageListDto) => {
  return request<PageResponse<API.quick.EntitySchema[]>>({
    url: '/admin/quick',
    method: 'get',
    params
  });
};

/**
 * 创建
 *
 * @returns Promise
 *
 * @todo 发起axios请求
 */
export const createQuick = (data: API.quick.EntityDto) => {
  return request({
    url: `/admin/quick`,
    method: 'post',
    data
  });
};

/**
 * 修改
 *
 * @returns Promise
 *
 * @todo 发起axios请求
 */
export const updateQuick = (id: number, data: API.quick.EntityDto) => {
  return request({
    url: `/admin/quick/${id}`,
    method: 'put',
    data
  });
};

// /**
//  * 更新switch状态
//  *
//  * @returns Promise
//  *
//  * @todo 发起axios请求
//  */
// export const updateSwitch = (
//   id: number,
//   data: { state?: boolean }
// ): Promise<any> => {
//   return request({
//     url: `/admin/quick/switch/${id}`,
//     method: 'put',
//     data
//   });
// };

/**
 * 删除
 *
 * @param id
 * @returns
 *
 * @todo 发起axios请求
 */
export const deleteQuick = (id: number): Promise<any> => {
  return request({
    url: `/admin/quick/${id}`,
    method: 'delete'
  });
};
